package com.heima.common.tess4j;

import net.sourceforge.tess4j.ITesseract;
import net.sourceforge.tess4j.Tesseract;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class Tess4JConfiguration {
    @Value("${tess4j.datapath}")
    private String datapath;
    @Value("${tess4j.language}")
    private String language;

    @Bean
    public ITesseract createTesseract(){
        ITesseract tesseract = new Tesseract();
        //加载语言库（除英文外的语言都需要加载语言库）
        tesseract.setDatapath(datapath);//设置语言库文件目录
        tesseract.setLanguage(language);
        return tesseract;
    }

}

